package com.zhaokuner.provider.application.backup.controller;


import com.zhaokuner.parentstarter.common.ResultData;
import com.zhaokuner.parentstarter.utils.MyAppContextUtil;
import com.zhaokuner.parentstarter.utils.MyCopyUtil;
import com.zhaokuner.provider.service.backup.controller.BackupTipConfirmControllerAdaptor;
import com.zhaokuner.provider.service.backup.model.ao.UserAO;
import com.zhaokuner.provider.service.backup.model.vo.UserVO;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
 * <p>
 * Description:备份文件用户确认表获取详情请求
 * <p>
 * Copyright: 联想集团  北京联想协同科技有限公司
 * <p>
 *
 * @author 赵希坤
 * @date 2020-12-15 20:47:00
 */
@Log4j2
@RestController
@RequestMapping("/backuppolicy/")
public class BackupTipConfirmController implements BackupTipConfirmControllerAdaptor {

    @Value("${lenovo.test}")
    private String test;

    @Override
    @RequestMapping("/annotationTest")
    public ResultData<List<UserVO>> annotationTest(String str, HttpServletRequest request) {
        return null;
    }

    @RequestMapping("/showtip")
    @Override
    public ResultData<List<UserVO>> showTip(String str, HttpServletRequest request) {
        log.info("test:" + test);
        log.info("showTip：{}", str);
        System.out.println("privated welcome:" + MyAppContextUtil.getMessage("welcome", null, request.getLocale()));
        System.out.println("privated seeyou:" + MyAppContextUtil.getMessage("seeyou", null, request.getLocale()));
        System.out.println("privated me:" + MyAppContextUtil.getMessage("me", null, request.getLocale()));
        System.out.println("privated seeyou:" + MyAppContextUtil.getMessage("seeyou", null, Locale.US));
        return ResultData.success(Arrays.asList(new UserVO("hanmeimei " + str, test + " " + MyAppContextUtil.getMessage("welcome", null, request.getLocale()), 2)));
    }

    @RequestMapping("/update")
    @Override
    public ResultData<UserVO> update(@RequestBody @Valid UserAO userAO) {
        UserVO vo = new UserVO();
        MyCopyUtil.copy(userAO, vo);
        vo.setH(test);
        return ResultData.success(vo);
    }
}
